<?php

/**
 * Description of tokenLoginAction
\* www.teuker.nl - mail@teuker.nl
 * 
 * @author francisc
 */

class tokenLoginAction extends sfAction {

    public function execute($request) {
        $token = $request->getParameter('token');
        
        $reservation = SqlEngine::getReservations(array('token' => $token));
        $settings = SqlEngine::getSettings(array('restaurant_id' => $reservation[0]['restaurant_id']));
        $restaurant = SqlEngine::getRestaurants(array('restaurant_id' => $reservation[0]['restaurant_id']));
        
        $this->getUser()->setAttribute('user_type', 'guest');
        Util::set_session_info($restaurant[0], $settings, $this->getUser());

        $this->redirect('@reservation_deep_link_guest?token=' . $token);
    }
}
